"""
权限分配类
"""
from selenium.webdriver.common.by import By
from pages.base_page import BasePage
from selenium.webdriver.common.action_chains import ActionChains


class PovertyPage(BasePage):
    kunkun_locator = (By.CSS_SELECTOR, "#browser > li > span > a:nth-child(2)")
    # 授权定位器
    competent_locator = (By.CSS_SELECTOR, "#control_file1 > a.permission")
    # 勾选定位器
    marketing_locator = (By.CSS_SELECTOR, "#dialog-authorize > form > table > tbody > tr:nth-child(11) > td:nth-child(1) > input")
    save_btn_locator = (By.ID, "sub_btn")
    cancel_btn_locator = (By.CSS_SELECTOR,"#dialog-authorize > form > table > tbody > tr:nth-child(14) > td:nth-child(2) > input:nth-child(2)")
    business_locator = (By.CSS_SELECTOR, "#dialog-authorize > form > table > tbody > tr:nth-child(3) > td:nth-child(1) > input")

    def move_kunkun(self,driver):
        """把鼠标移到坤坤"""
        action_chains=ActionChains(driver)
        kunkun_element=self.driver.find_element(*self.kunkun_locator)
        action_chains.move_to_element(kunkun_element).perform()

    def click_competent(self):
        """点击授权"""
        self.driver.find_element(*self.competent_locator).click()

    def click_market(self):
        """勾选营销"""
        self.driver.find_element(*self.marketing_locator).click()

    def click_save_btn(self):
        """点击保存"""
        self.driver.find_element(*self.save_btn_locator).click()

    def click_business(self):
        """勾选商机"""
        self.driver.find_element(*self.business_locator).click()

    def click_cancel(self):
        """点击取消"""
        self.driver.find_element(*self.cancel_btn_locator).click()

